package comp512.classes;

import java.io.Serializable;

/**
 * This is the class to store the answer object.
 * 
 * @author Siddharth Dahiya & Ronny Arias
 * 
 */
public class Answer implements Serializable, Comparable<Answer> {
	private static final long serialVersionUID = 1L;
	private String answer;
	private int weight;

	public Answer() {
		answer = "";
		weight = -1;
	}

	public Answer(String answer, int weight) {
		this.answer = answer.toLowerCase();
		this.weight = weight;
	}

	public void setAnswer(String answer) {
		this.answer = answer.toLowerCase();
	}

	public String getAnswer() {
		return answer;
	}

	public void setWeight(int weight) {
		this.weight = weight;
	}

	public int getWeight() {
		return weight;
	}
	
	public String getWeightString(){
		return String.valueOf(weight);
	}

	public String toString() {
		return answer + "," + weight;
	}

	@Override
	public int compareTo(Answer o) {
		if (this.weight < o.getWeight())
			return -1;
		else if(this.weight > o.getWeight())
			return 1;
		return 0;
	}
}
